<?php
/*************************************************
 * file description
 * @filename:           ViewClassModel.class.php
 * @desc:               老师，学生，班级信息视图
 * @tables:             [dd_view_class]
 * @date:               2016-10-05
 * @author:             大业
 * @version:            v1.0
 *************************************************/
namespace Common\Model;

use Common\Model\BaseModel;
//注：该功能暂时已废弃，后续如果需要时，再补充完善 
class ViewClassModel extends BaseModel
{
    /**
     * [获取班级中的老师和学生信息]
     * @method getClassInfo
     * @auther 大业
     * @create 2016-10-02
     * @param  [type] $condition [description]
     * @return [type] [description]
     */
    public function getClassInfo($condition)
    {
        if(empty($condition)){
            $condition='1 = 1';
        }
        $where = $condition." and cla_type = 2";//2为班级
        $info = $this->showInfo('',$condition,'admin')['list'];
        dump($info);
        foreach ($info as $key => $value) {
            $list[$key]['name']		= $value['cla_desc'].$value['cla_name'];
            $list[$key]['tea_list']	= $this->getTeacherList($value['cla_no']);
            //$list[$key]['stu_list']	= $this->getStudentList($value['cla_no']);
        }
        dump($list);exit;
    }

    private function getTeacherList($claNo)
    {
        $field = 'tea_id';
        $where = "cla_no = '".$claNo."'";
        $info = D('ClassToTeacher')->selectData($where,$field);
        foreach ($info as $k => $tid) {
            $teaInfo = D('TeacherInfo')->findData('id ='.$tid);
            $list[$k]['id']	= $teaInfo['id'];
            $list[$k]['name']	= $teaInfo['tea_name'];
        }
        dump($info);
    }


}
